﻿using pdfer.FileObjects;
using pdfer.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pdfer.PdfObjecs
{
    internal class OutlinesDictionary : PdfFileObject
    {
        public OutlinesDictionary(PdfFileObject pdfFileObject)
            : base(pdfFileObject)
        {

        }
        private String _first;
        private String _prev;
        private String _next;
        private String _last;
        private Int32? _count;
        private String _parent;
        private String _title;
        private List<Object> _dest;
        private String _a;
        /// <summary>
        /// 子节点第一个
        /// </summary>
        public String? First 
        {
            get
            {
                if(_first == null && TryGetValue(PdfName.Key_First, out var obj))
                {
                    _first = PdfParserUtils.ParseString(obj);
                }
                return _first;
            }
        }

        /// <summary>
        /// 前一个
        /// </summary>
        public String? Prev
        {
            get
            {
                if (_prev == null && TryGetValue(PdfName.Key_Prev, out var obj))
                {
                    _prev = PdfParserUtils.ParseString(obj);
                }
                return _prev;
            }
        }
        /// <summary>
        /// 后一个
        /// </summary>
        public String? Next
        {
            get
            {
                if (_next == null && TryGetValue(PdfName.Key_Next, out var obj))
                {
                    _next = PdfParserUtils.ParseString(obj);
                }
                return _next;
            }
        }

        /// <summary>
        /// 子节点最后一个
        /// </summary>
        public String? Last
        {
            get
            {
                if (_last == null && TryGetValue(PdfName.Key_Last, out var obj))
                {
                    _last = PdfParserUtils.ParseString(obj);
                }
                return _last;
            }
        }
        /// <summary>
        /// 子节点个数
        /// </summary>
        public Int32? Count
        {
            get
            {
                if (_count == null && TryGetValue(PdfName.Key_Count, out var obj))
                {
                    _count = ParseInt32(obj);
                }
                return _count;
            }
        }
        /// <summary>
        /// 父节点
        /// </summary>
        public String? Parent
        {
            get
            {
                if (_parent == null && TryGetValue(PdfName.Key_Parent, out var obj))
                {
                    _parent = PdfParserUtils.ParseString(obj);
                }
                return _parent;
            }
        }
        /// <summary>
        /// 标题
        /// </summary>
        public String? Title
        {
            get
            {
                if (_title == null && TryGetValue(PdfName.Key_Title, out var obj))
                {
                    _title = PdfParserUtils.ParseString(obj);
                }
                return _title;
            }
        }

        public List<Object>? Dest
        {
            get
            {
                if (_dest == null && TryGetValue(PdfName.Key_Dest, out var obj))
                {
                    _dest = ParseList(obj, PdfParserUtils.Trans2Object);
                }
                return _dest;
            }
        }

        public String A
        {
            get
            {
                if (_a == null && TryGetValue(PdfName.Key_A, out var obj))
                {
                    _a = PdfParserUtils.ParseString(obj);
                }
                return _a;
            }
        }
    }
}
